<?php

namespace Cck\ArticlesSystem\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class SettingGroupUpdateRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $id = $this->route('setting_group')->id;
        return [
            'display_name' => [
                'required',
                'max:30',
                Rule::unique('setting_groups', 'display_name')->ignore($id)
            ],
            'name' => [
                'required',
                'max:50',
                Rule::unique('setting_groups', 'name')->ignore($id)
            ],
            'enable' => [
                'sometimes',
                'boolean'
            ],
            'order' => [
                'sometimes',
                'integer',
                'min:0',
                'max:255'
            ]
        ];
    }
}
